#!/usr/bin/env bash

# DESCRIPTION
#     Applies to: SteamOS, Chinese and Japanese keyboard layout
#     This script enables the Chinese and Japanese locale files and regenerates them.
#
# NOTES
#     The changes done by this script might be undone by system updates.
#
# AUTHOR
#     Bluefissure (2023)

sudo steamos-readonly disable
sudo pacman-key --init
sudo pacman-key --populate archlinux

# Update glibc
sudo pacman -S glibc

# Enable (uncomment) the locale
sudo sed -i "s%#ja_JP.UTF-8 UTF-8%ja_JP.UTF-8 UTF-8%" /etc/locale.gen
sudo sed -i "s%#zh_CN.UTF-8 UTF-8%zh_CN.UTF-8 UTF-8%" /etc/locale.gen

# Regenerate all enabled locale
sudo locale-gen
sudo steamos-readonly enable

echo "Next steps:"
echo "1. In Steam: use the start options 'LANG=ja_JP.UTF-8 %command%' or 'LANG=zh_CN.UTF-8 %command%'"
echo "2. Restart steamOS before starting the game"
